package com.hhxy.login.utils;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.mysql.cj.xdevapi.Collection;

import javax.activation.MailcapCommandMap;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.*;
import java.util.stream.Stream;

/**
 * @auther:Lu Yao
 * @date:2022/3/9
 *
 *
 **/
public class MyPcMessage {
    public static String getNetWorkInterface(){
        try {
            Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
           while (networkInterfaces.hasMoreElements()){
               NetworkInterface networkInterface = networkInterfaces.nextElement();
               if (null!=networkInterface){
                   if (null!=networkInterface.getHardwareAddress()){
                       byte[] hardwareAddress = networkInterface.getHardwareAddress();
                       System.out.println(getMacString(hardwareAddress));
                   }
               }
           }
        } catch (SocketException e) {
            e.printStackTrace();
        }
        return "a";
    }
    private static byte[] getMacBytes(String mac) {
        byte[] macBytes = new byte[6];

        String[] strArr = mac.split(":");
        for (int i = 0; i < strArr.length; i++) {
            int value = Integer.parseInt(strArr[i], 16);
            macBytes[i] = (byte) value;
        }

        return macBytes;
    }

    /**
     * 将Mac地址的数组形式转换为字符串形式
     * @param macBytes mac地址的数组形式
     * @return Mac地址的字符串，格式如：78:44:fd:c9:87:a0
     */
    private static String getMacString(byte[] macBytes) {
        StringBuilder builder = new StringBuilder();
        System.out.println(macBytes.length);
        for (int i = 0; i < macBytes.length; i++) {
            builder.append(':').append(Integer.toHexString(0xFF & macBytes[i]));
        }
        return builder.substring(1);
    }

    public static void main(String[] args) {
        List<String> list = Lists.newArrayList();
       list.add("1");
       list.add("2");
       list.add("3");
       //
       Map map=new HashMap<>();
       list.forEach(a->{
           if (a=="2"){
               //list.remove("2");
               //list.add(0,a);
               map.put("1", "2");
               System.out.println(a);
           }
       });

       List s=new ArrayList();
        list.forEach(a->{
            s.add("1");
        });
        String s1="";
        list.forEach(a->{
            s1.substring(0);
        });
        System.out.println(list);


    }
}